<template>
  <div class="profile">
    <h2>个人信息</h2>
    
    <el-card shadow="hover" class="profile-card">
      <div class="profile-header">
        <div class="avatar">
          <el-avatar :size="80" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
        </div>
        <div class="info">
          <h3>{{ userStore.username }}</h3>
          <p>系统管理员</p>
        </div>
      </div>
      
      <el-divider />
      
      <el-form label-position="right" label-width="100px" :model="userForm">
        <el-form-item label="用户名">
          <el-input v-model="userForm.username" disabled />
        </el-form-item>
        <el-form-item label="电子邮箱">
          <el-input v-model="userForm.email" />
        </el-form-item>
        <el-form-item label="手机号码">
          <el-input v-model="userForm.phone" />
        </el-form-item>
        <el-form-item label="所属部门">
          <el-input v-model="userForm.department" />
        </el-form-item>
        <el-form-item label="个人简介">
          <el-input type="textarea" v-model="userForm.bio" :rows="4" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="saveProfile">保存信息</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useUserStore } from '../store/user'
import { ElMessage } from 'element-plus'

const userStore = useUserStore()

// 用户表单数据
const userForm = ref({
  username: userStore.username || '用户',
  email: 'user@example.com',
  phone: '13800138000',
  department: '技术部',
  bio: '这是一段个人简介，您可以在此处介绍自己。'
})

// 保存用户信息
const saveProfile = () => {
  ElMessage({
    message: '个人信息保存成功！',
    type: 'success'
  })
}
</script>

<style scoped>
.profile {
  padding: 10px;
  width: 100%;
}

.profile-card {
  max-width: 800px;
  margin: 20px auto;
  width: 95%;
}

.profile-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.avatar {
  margin-right: 20px;
}

.info h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
}

.info p {
  margin: 0;
  color: #909399;
}
</style> 